#include "mavlink_wrapper.h"

// 解析
int parse_mavlink_message(const uint8_t* buffer, int length, mavlink_message_t* out_msg)
{
    mavlink_status_t status;
    for (int i = 0; i < length; i++) {
        if (mavlink_parse_char(MAVLINK_COMM_0, buffer[i], out_msg, &status)) {
            return 1; // 完整消息
        }
    }
    return 0;
}

// 打包 heartbeat
int pack_heartbeat(uint8_t system_id, uint8_t component_id, mavlink_message_t* out_msg)
{
    mavlink_msg_heartbeat_pack(
        system_id,
        component_id,
        out_msg,
        MAV_TYPE_QUADROTOR,
        MAV_AUTOPILOT_GENERIC,
        MAV_MODE_MANUAL_ARMED,
        0,
        MAV_STATE_STANDBY
    );
    return 1;
}